<?php


class ApiError extends Exception
{
    //线上环境
    private static $product = false;

    protected $msg = "";

    public function __construct($message = "", $code = 0, Throwable $previous = null)
    {
        $this->msg = $message;
        parent::__construct($message, $code, $previous);
    }

    public static function setProduct(bool $status)
    {
        self::$product = $status;
    }

    public function getError()
    {
        if (self::$product) tools::dd($this->msg); //正式环境记录错误信息
        return  $this->msg;
    }
}